package www.lagou.dao;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import www.lagou.entity.Dept;
import www.lagou.utils.DruidUtils;

import java.sql.SQLException;

public class DeptDao {

    // 通过 id 查找 dept 信息
    public Dept findByid(int id) throws SQLException {

        QueryRunner qr = new QueryRunner(DruidUtils.getDataSource());

        String sql = "select * from dept where id = ?";

        Dept query = qr.query(sql, new BeanHandler<>(Dept.class), id);

        return query;
    }
}
